package cate.common.table.activity.godtree.sheet;

import cate.common.table.ESheet;
import cate.common.table.activity.godtree.row.MonsterConfigRow;

import java.util.List;
import java.util.stream.Collectors;

public class MonsterConfigSheet extends ESheet<MonsterConfigRow> {
    @Override
    public String getSheetName() {
        return "果实配置";
    }


    public MonsterConfigRow getRowByLevelAndNum(int level, int num) {
        MonsterConfigRow res = null;
        for (MonsterConfigRow row : getList()) {
            if (row.level == level && row.num == num) {
                res = row;
            }
        }
        return res;
    }

    public List<MonsterConfigRow> getRowsByLevel(int level) {
        return getList().stream().filter(row -> row.level == level).collect(Collectors.toList());
    }

    public MonsterConfigRow getMaxRow(int level) {
        return getList().stream().filter(row -> row.level == level).reduce(get(0), (r1, r2) -> r1.num > r2.num ? r1 : r2);
    }
}
